<template>
  <div>
    <el-container style="height: 100vh; border: 1px solid #eee">
      <el-header style="text-align: right; font-size: 12px">
        <div class="logo-title">
          <a href="localhost:8080"></a>
          <img src="../assets/logo.png" alt="王者荣耀">
          <h2>王者荣耀后台管理系统</h2>
        </div>
        <div>
          <el-button type="text" size="middle" style="color: grey">
            <i class="el-icon-switch-button" style="color: #fdb933"></i> &nbsp;&nbsp;退出
          </el-button>
        </div>
      </el-header>
      <el-container>
        <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
          <el-menu router :default-active="this.$route.path" unique-opened>
            <el-submenu index="1">
              <template slot="title"><i class="el-icon-s-fold"></i>分类</template>
              <el-menu-item-group>
                <el-menu-item index="/categories/create" @click="reloadRouter('/categories/create')">新建分类</el-menu-item>
                <el-menu-item index="/categories/list" @click="reloadRouter('/categories/list')">分类列表</el-menu-item>
              </el-menu-item-group>
            </el-submenu>

            <el-submenu index="2">
              <template slot="title"><i class="el-icon-menu"></i>物品管理</template>
              <el-menu-item-group>
                <el-menu-item index="/items/create">新建物品</el-menu-item>
                <el-menu-item index="/items/list">物品列表</el-menu-item>
              </el-menu-item-group>
            </el-submenu>

            <el-submenu index="3">
              <template slot="title"><i class="el-icon-user-solid"></i>英雄管理</template>
              <el-menu-item-group>
                <el-menu-item index="/heroes/create">新建英雄</el-menu-item>
                <el-menu-item index="/heroes/list">英雄列表</el-menu-item>
              </el-menu-item-group>
            </el-submenu>

            <el-submenu index="4">
              <template slot="title"><i class="el-icon-document"></i>文章管理</template>
              <el-menu-item-group>
                <el-menu-item index="/articles/create">新建文章</el-menu-item>
                <el-menu-item index="/articles/list">文章列表</el-menu-item>
              </el-menu-item-group>
            </el-submenu>

            <el-submenu index="5">
              <template slot="title"><i class="el-icon-s-promotion"></i>广告管理</template>
              <el-menu-item-group>
                <el-menu-item index="/ads/create">新建广告</el-menu-item>
                <el-menu-item index="/ads/list">广告列表</el-menu-item>
              </el-menu-item-group>
            </el-submenu>

            <el-submenu index="6">
              <template slot="title"><i class="el-icon-setting"></i>系统设置</template>
              <el-menu-item-group>
                <el-menu-item index="/admins/create">新建管理员</el-menu-item>
                <el-menu-item index="/admins/list">管理员列表</el-menu-item>
              </el-menu-item-group>
            </el-submenu>

          </el-menu>
        </el-aside>
        <el-main>
          <!-- :key='$route.path' -->
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  methods: {
    //实现路由的局部刷新
    reloadRouter(path) {
      this.$router.replace({
        path: "/redirect",
        query: {
          nextPath: path,
        },
      });
    },
  },
};
</script>

    
<style>
.el-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #eef1f6;
}
.logo-title {
  display: flex;
  align-items: center;
}

.el-aside {
  color: #333;
}
</style>